const mongoose = require('mongoose')
const baseModel = require('./base-model')
const md5 = require('../util/md5')
// 用户数据模型
const userSchema = new mongoose.Schema({
  ...baseModel,
  "username": {
    type: String,
    require: true
  },
  "email": {
    type: String,
    require: true
  },
  "password": {
    type: String,
    require: true,
    set: v=>md5(v),
    select: false
  },
  bio: {
    type: String,
    default: null
  },
  image: {
    type: String,
    default: null
  }
});

module.exports = userSchema